package com.sskj.postar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class ShopController {
    //    @Autowired
//    private StockRepository stockRepository;
//    @GetMapping(path="/buy/{stockId}")
//    public @ResponseBody String buy (@PathVariable("stockId") Long stockId) {
//        stockRepository.buy(stockId);
//        return "OK";
//    }
    @Autowired
    StringRedisTemplate template;

    @GetMapping(path = "/buy/{stockId}")
    public String buy(@PathVariable("stockId") Long stockId) {
        template.convertAndSend("shop", stockId.toString());
        return "OK";
    }

}
